//
//  HMStatusViewModel.swift
//  WeiBo
//
//  Created by Apple on 16/9/21.
//  Copyright © 2016年 KY. All rights reserved.
//

import UIKit

//  cell逻辑处理对应的ViewModel
class HMStatusViewModel: NSObject {

    //  持有模型
    var status: HMStatus?
    
    //  转发数内容
    var retweetCountContent: String?
    //  评论数内容
    var commentCountContent: String?
    //  赞数内容
    var unLinkCountContent: String?
    
    init(status: HMStatus) {
        super.init()
        self.status = status
        
        retweetCountContent = handleCount(count: status.reposts_count, defaultTitle: "转发")
        commentCountContent = handleCount(count: status.comments_count, defaultTitle: "评论")
        unLinkCountContent = handleCount(count: status.attitudes_count, defaultTitle: "赞")
    }
    
    //  根据数量显示toolbar内容
    private func handleCount(count: Int, defaultTitle: String) -> String {
        
        //  数量大于0 正常显示否则 显示默认值的标题
        if count > 0 {
            return "\(count)"
        }
        
        return defaultTitle
    
    }
    
    
    
}
